
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;



namespace Microsoft.NETMF.BikeComputer.Application
{
    public class SettingsView : View
    {



        private UpDownArrowButton _setTireSize;
        private UpDownArrowButton _setUnits;
        private UIButton _zeroInclinometer;


        public SettingsView(RideDataModel model, ComputerController controller)
            : base(model)
        {

            StackPanel settingsPanel = new StackPanel(Orientation.Vertical);  
            settingsPanel.HorizontalAlignment = HorizontalAlignment.Center;
            settingsPanel.VerticalAlignment = VerticalAlignment.Center;

            ////////////////////////////////////////////////////////////////////////////////////////
            //  title area
            //

            StackPanel titlePanel = new StackPanel(Orientation.Vertical);
            titlePanel.HorizontalAlignment = HorizontalAlignment.Center;
            titlePanel.VerticalAlignment = VerticalAlignment.Top;
            titlePanel.SetMargin(10, 0, 10, 0);

            Text titleText = new Text (Resources.GetFont(Resources.FontResources.nina48),Resources.GetString(Resources.StringResources.SettingsTitle));
            titleText.HorizontalAlignment = HorizontalAlignment.Center;
            titleText.VerticalAlignment = VerticalAlignment.Top;

            titlePanel.Children.Add(titleText);

            ////////////////////////////////////////////////////////////////////////////////////////
            //  input area
            //
            
            StackPanel inputPanel = new StackPanel(Orientation.Horizontal);

            StackPanel tireSizePanel = new StackPanel(Orientation.Vertical);
            tireSizePanel.SetMargin(10, 10, 40,15);

            Text TireLabel = new Text(Resources.GetFont(Resources.FontResources.miramob), Resources.GetString(Resources.StringResources.TireSize));

            _setTireSize = new UpDownArrowButton(model.TireSizes);

            tireSizePanel.Children.Add(TireLabel);
            tireSizePanel.Children.Add(_setTireSize);

            StackPanel unitsPanel = new StackPanel(Orientation.Vertical);
            unitsPanel.SetMargin(40, 10, 10, 15);

            Text UnitsLabel = new Text(Resources.GetFont(Resources.FontResources.miramob), Resources.GetString(Resources.StringResources.Units));

            _setUnits = new UpDownArrowButton(model.Units);

            unitsPanel.Children.Add(UnitsLabel);
            unitsPanel.Children.Add(_setUnits);

            StackPanel ButtonPanel = new StackPanel(Orientation.Vertical);
            ButtonPanel.VerticalAlignment = SPOT.Presentation.VerticalAlignment.Center;

            ButtonPanel.SetMargin(40, 10, 10, 15);

            _zeroInclinometer = new UIButton(Resources.GetString(Resources.StringResources.inclineButtonText),Resources.GetFont(Resources.FontResources.miramob));
           // _zeroInclinometer.TouchUp += new TouchEventHandler(controller._zeroInclinometer_TouchUp);
            _zeroInclinometer.Click += new EventHandler(controller._zeroInclinometer_Click);

            ButtonPanel.Children.Add(_zeroInclinometer);

            inputPanel.Children.Add(tireSizePanel);
            inputPanel.Children.Add(unitsPanel);
            inputPanel.Children.Add(ButtonPanel);
            
            /////////////////////////////////////////////////////////////////////////////////////////////////
            //  Date area
            //
            StackPanel datePanel = new StackPanel(Orientation.Vertical);
            datePanel.HorizontalAlignment = HorizontalAlignment.Center;
            datePanel.VerticalAlignment = VerticalAlignment.Bottom;

            Text dateTime = new Text(Resources.GetFont(Resources.FontResources.miramob), model.getToday().ToString());

            datePanel.Children.Add(dateTime);

            ///////////////////////////////////////////////////////////////////////////////////////
            //  panel Setup
            //

            settingsPanel.Children.Add(titlePanel);
            settingsPanel.Children.Add(inputPanel);
            settingsPanel.Children.Add(datePanel);

            Child = settingsPanel;

        }




    }
}
